<?php

function rpc( $json_request ) {
    global $PARAPARA;

    $req_param = $json_request->param;

    if(!$req_param) {
        return new RPC_Error($json_request->operation, "PARAM", "No params");
    };

    $id_list = $req_param->ids;
    if( !$id_list || !is_array( $id_list) )
        return new RPC_Error($json_request->operation, "PARAM", "Mising ids list");

    $account = $PARAPARA->fetch_account();

    // check if user has admin rights
    if(  !$account || (!$account->is_admin() ) )  
        return new RPC_Error($json_request->operation, "AUTH", "Not authorized");

    $dbl    = $PARAPARA->dblayer;
    $status = $dbl->del_chat_messages( $id_list );

    $rpc_retval = array( 'status' => $status );

    return new RPC_Response( $json_request->operation, $rpc_retval );

}

return rpc( $json_request );

?>